home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH1 / SRC / VIEWER.FRM < prev    next >
Text File  |  1995-12-18  |  4KB  |  155 lines

  1. VERSION 4.00
  2. Begin VB.Form ViewerForm 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    Caption         =   "Viewer"
  6.    ClientHeight    =   4425
  7.    ClientLeft      =   1275
  8.    ClientTop       =   1365
  9.    ClientWidth     =   6915
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   5115
  21.    Left            =   1215
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   4425
  24.    ScaleWidth      =   6915
  25.    Top             =   735
  26.    Width           =   7035
  27.    Begin VB.ComboBox PatternCombo 
  28.       Appearance      =   0  'Flat
  29.       Height          =   315
  30.       Left            =   120
  31.       Style           =   2  'Dropdown List
  32.       TabIndex        =   3
  33.       Top             =   3960
  34.       Width           =   2415
  35.    End
  36.    Begin VB.FileListBox filList 
  37.       Appearance      =   0  'Flat
  38.       Height          =   1980
  39.       Left            =   120
  40.       Pattern         =   "*.ico;*.bmp;*.wmf;*.dib"
  41.       TabIndex        =   2
  42.       Top             =   1920
  43.       Width           =   2415
  44.    End
  45.    Begin VB.DirListBox dirList 
  46.       Appearance      =   0  'Flat
  47.       Height          =   1380
  48.       Left            =   120
  49.       TabIndex        =   1
  50.       Top             =   480
  51.       Width           =   2415
  52.    End
  53.    Begin VB.DriveListBox drvList 
  54.       Appearance      =   0  'Flat
  55.       Height          =   315
  56.       Left            =   120
  57.       TabIndex        =   0
  58.       Top             =   120
  59.       Width           =   2415
  60.    End
  61.    Begin VB.Image bigImage 
  62.       Appearance      =   0  'Flat
  63.       Height          =   4215
  64.       Left            =   2640
  65.       Top             =   120
  66.       Width           =   4215
  67.    End
  68.    Begin VB.Menu mnuFile 
  69.       Caption         =   "&File"
  70.       Begin VB.Menu mnuFileExit 
  71.          Caption         =   "E&xit"
  72.       End
  73.    End
  74. End
  75. Attribute VB_Name = "ViewerForm"
  76. Attribute VB_Creatable = False
  77. Attribute VB_Exposed = False
  78. Option Explicit
  79.  
  80. Private Sub dirList_Change()
  81.     filList.Path = dirList.Path
  82. End Sub
  83.  
  84. Private Sub drvList_Change()
  85.     On Error GoTo DriveError
  86.     dirList.Path = drvList.Drive
  87.     Exit Sub
  88.  
  89. DriveError:
  90.     drvList.Drive = dirList.Path
  91.     Exit Sub
  92. End Sub
  93.  
  94.  
  95.  
  96. Private Sub filList_Click()
  97. Dim fname As String
  98.  
  99.     On Error GoTo LoadPictureError
  100.  
  101.     fname = filList.Path + "\" + filList.filename
  102.     bigImage.Picture = LoadPicture(fname)
  103.     Caption = "Viewer [" & fname & "]"
  104.     Exit Sub
  105.  
  106. LoadPictureError:
  107.     Beep
  108.     Caption = "Viewer [Invalid picture]"
  109.     Exit Sub
  110. End Sub
  111.  
  112. Private Sub Form_Load()
  113.     PatternCombo.AddItem "(*.bmp;*.ico;*.rle;*.wmf)"
  114.     PatternCombo.AddItem "Bitmap (*.bmp)"
  115.     PatternCombo.AddItem "Icon (*.ico)"
  116.     PatternCombo.AddItem "Run-Length Encoded (*.rle)"
  117.     PatternCombo.AddItem "Metafile (*.wmf)"
  118.     PatternCombo.AddItem "All Files (*.*)"
  119.     PatternCombo.ListIndex = 0
  120. End Sub
  121.  
  122. Private Sub Form_Resize()
  123. Const GAP = 60
  124.  
  125. Dim wid As Single
  126. Dim hgt As Single
  127.  
  128.     If WindowState = 1 Then Exit Sub
  129.  
  130.     wid = drvList.Width
  131.     drvList.Move GAP, GAP, wid
  132.     PatternCombo.Move GAP, ScaleHeight - PatternCombo.Height - GAP, wid
  133.     
  134.     hgt = (PatternCombo.Top - drvList.Top - drvList.Height - GAP) / 2
  135.     If hgt < 100 Then hgt = 100
  136.     dirList.Move GAP, drvList.Top + drvList.Height + GAP, wid, hgt
  137.     filList.Move GAP, dirList.Top + dirList.Height + GAP, wid, hgt
  138. End Sub
  139.  
  140. Private Sub mnuFileExit_Click()
  141.     Unload Me
  142. End Sub
  143.  
  144. Private Sub PatternCombo_Click()
  145. Dim pat As String
  146. Dim p1 As Integer
  147. Dim p2 As Integer
  148.  
  149.     pat = PatternCombo.List(PatternCombo.ListIndex)
  150.     p1 = InStr(pat, "(")
  151.     p2 = InStr(pat, ")")
  152.     filList.Pattern = Mid$(pat, p1 + 1, p2 - p1 - 1)
  153. End Sub
  154.  
  155.